<!-- 停车休息 22-->
<template>
	<view class="add-box">
		<view class="info shadow radius">
			<view class="info-label">
				<text>停车休息</text>
			</view>
			<view class="info-item">
				<text class="text">休息时间</text>
				<input type="text" class="input" v-model="info.datetime" disabled />
			</view>
			<view class="info-item">
				<text class="text">天气情况</text>
				<select-weather class="input" placeholder="请选择天气情况" v-model="info.weather"></select-weather>
			</view>
			<view class="info-item">
				<text class="text">休息地点</text>
				<input type="text" class="input" placeholder="请输入休息地点" v-model="info.recordPlace" />
			</view>
			<view class="info-item">
				<text class="text">休息时长</text>
				<input type="text" class="input" placeholder="请输入休息时长" v-model="info.logContent" />
			</view>
			<view class="info-item">
				<text class="text">备注说明</text>
				<input type="text" class="input" placeholder="请输入备注说明" v-model="info.note" />
			</view>
		</view>
		<view class="add-btns">
			<view class="btn-cancel" @click="$goBack(1,1)">
				<text>取 消</text>
			</view>
			<view class="btn-submit" @click="submit">
				<text>确 认</text>
			</view>
		</view>
	</view>
</template>


<script>
	import {
		dateFormat
	} from "@/common/util.js"
	import selectWeather from '@/components/tool-select/select-weather.vue';
	export default {
		props: ['param'],
		components: {
			selectWeather
		},
		data() {
			return {
				info: {
					logType: '22', // 收车后检查
					datetime: '', // 当前时间
					weather: "", // 天气
					recordPlace: "", // 请输入休息地址
					logContent: "", // 休息时长
					note: '', // 备注说明
				},
			};
		},
		watch: {},
		methods: {
			submit() {
				Object.assign(this.info, this.param);
				const formData = this.info;
				if (!formData.weather) {
					uni.showToast({
						icon: 'none',
						title: '请选择天气'
					})
					return false;
				}
				if (!formData.weather) {
					uni.showToast({
						icon: 'none',
						title: '请输入休息地址'
					})
					return false;
				}
				if (!formData.weather) {
					uni.showToast({
						icon: 'none',
						title: '请输入休息时长'
					})
					return false;
				}
				// console.log(formData);
				this.$api.mgntvehrunlogSave(formData).then(res => {
					console.log(res)
					uni.showToast({
						title: "已提交",
						success() {
							setTimeout(() => {
								let pages = getCurrentPages(); // 当前页面        
								let beforePage = pages[pages.length - 2]; // 上上一页 
								uni.navigateBack({
									success: () => {
										beforePage.$vm.busibillDatail();
									}
								});
							}, 1500); // showToast默认时间
						}
					})
				})
			}
		},
		mounted() {
			this.$nextTick(() => {
				// 在此处给个默认当前时间
				this.info.datetime = dateFormat();
			})
		}
	}
</script>

<style lang="scss" scoped>
	.add-box {

		.add-btns {
			text-align: center;
			padding: 40rpx 0;

			.btn-cancel,
			.btn-submit {

				display: inline-block;
				margin: 0 30rpx;
				border-radius: 50rpx;
				padding: 0 80rpx;
				font-size: 32rpx;
			}

			.btn-cancel {
				border: 2rpx solid #CCCCCC;
				line-height: 80rpx;
			}

			.btn-submit {
				line-height: 84rpx;
				background-color: $app-color;
			}
		}
	}

	.info {
		background-color: #fff;
		margin-bottom: 30rpx;

		.info-label {
			position: relative;
			padding: 20rpx 0;
			border-bottom: 2rpx solid #dddddd;

			text {
				font-size: 32rpx;
			}

			&::after {
				content: "";
				position: absolute;
				left: -30rpx;
				top: 50%;
				transform: translateY(-50%);
				width: 6rpx;
				height: 38rpx;
				background-color: $app-color;
			}
		}

		.info-item {
			display: flex;
			padding: 30rpx 0;
			border-bottom: 2rpx solid #dddddd;

			.text {
				font-size: 28rpx;
				line-height: 40rpx;
				color: #666666;
				width: 4em;
				text-align: justify;
				text-align-last: justify;
			}

			.input {
				font-size: 30rpx;
				line-height: 40rpx;
				height: 40rpx;
				flex: 1;
				padding: 0 20rpx;
			}

			.date-select {
				flex: 1;

				::v-deep .uni-date-x--border {
					border: 0;

					.uni-date-x {
						padding: 0 10rpx;
					}

					.uni-icons {
						display: none;
					}

					.uni-date__x-input {
						line-height: 36rpx;
						height: 36rpx;
					}

					.uni-input-input {
						font-size: 28rpx;
					}
				}
			}

		}

		>.info-item:last-child {
			border-bottom: 0;
		}

	}
</style>
